package br.ufmg.ubicomp.droidguide.util;

import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class DroidGuideServerUtil {

	public static Map<String, Object> convertUrlToParams(String url)
	{
		Map<String, Object> params = new HashMap<String, Object>();
		
		int pos = url.indexOf("?");
		
		String parameters = url.substring(pos+1);
		
		StringTokenizer tokenizer = new StringTokenizer(parameters, "&");
		
		while (tokenizer.hasMoreTokens())
		{
			String s = tokenizer.nextToken();
			StringTokenizer token2 = new StringTokenizer(s, "=");
			while (token2.hasMoreTokens())
			{
				String paramName = token2.nextToken();
				String paramValue = token2.nextToken();
				params.put(paramName, paramValue);
			}
		}
		
		return params;
	}
	
}
